import requests


headers = {
    "sec-ch-ua-platform": "\"Windows\"",
    "Referer": "https://www.xinpianchang.com/",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
    "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"",
    "Range": "bytes=0-",
    "sec-ch-ua-mobile": "?0"
}
url = "https://us-xpc5-l2.xpccdn.com/a951adea-71aa-40b6-bc9e-94b805b95bd9/533dfd83-8112-4469-96f5-50872dd28003.mp4"
params = {
    "j": "{\"userId\":0,\"deviceId\":\"34m0k1f3pvmdebzwmv\",\"ip\":\"123.160.225.184,1.194.253.55\"}"
}
response = requests.get(url, headers=headers, params=params)
# print(response.text)

filename = "video.mp4"

# 以二进制写入模式打开文件
with open(filename, 'wb') as f:
    # 分块写入内容，适合大文件
    for chunk in response.iter_content(chunk_size=1024):
        if chunk:  # 过滤掉保持连接的空块
            f.write(chunk)
print(f"视频已成功保存为: {filename}")

